/**
 * Created by smp on 2017/4/10.
 */
$('#cardSave').on('click',function () {
    var index=layer.confirm('是否确定保存？', {
        btn: ['确定','取消'] //按钮
    }, function(){
        if($("#handleOpinion").textbox("getValue")==null||$("#handleOpinion").textbox("getValue")==""){
            layer.close(index);
            layer.msg('带*号的必填', {
                icon: 2,
                time: 2000
            });
            return;
        }
        $('#cardForm').form('submit', {
            url: ROOT_PATH+'/observation/observationCard/handleCard.shtml',

            onSubmit: function (param) {
                var isValid = $(this).form('validate');
                if (!isValid) {
                    layer.close(index);
                    layer.msg("请正确填写表单")
                }
                return $(this).form('validate');
            },
            success: function (result) {
                result = $.parseJSON(result);
                if (result.success){
                    //$.messager.progress('close');	// 如果提交成功则隐藏进度条
                    parent.layer.msg(result.message,{time:1000,icon:1},function () {
                        parent.$('#dg1').datagrid('load');
                        parent.layer.closeAll(); //先得到当前iframe层的索引
                    });
                }else {
                    //$.messager.progress('close');	// 如果提交成功则隐藏进度条
                    parent.layer.msg(result.message,{time:1000,icon:2});
                }
            }
        });
    });

});
//表单提交
$('#cardBack').on('click',function () {
    var index=layer.confirm('是否确定保存？', {
        btn: ['确定','取消'] //按钮
    }, function(){
        $('#cardForm').form('submit', {
            url: ROOT_PATH+'/observation/observationCard/reject.shtml',
            onSubmit: function (param) {
                var isValid = $(this).form('validate');
                if (!isValid) {
                    layer.close(index);
                    layer.msg("请正确填写表单")
                }
                return $(this).form('validate');
            },
            success: function (result) {
                result = $.parseJSON(result);
                if (result.success){
                    //$.messager.progress('close');	// 如果提交成功则隐藏进度条
                    parent.layer.msg(result.message,{time:1000,icon:1},function () {
                        parent.$('#dg1').datagrid('load');
                        parent.layer.closeAll(); //先得到当前iframe层的索引
                    });
                }else {
                    //$.messager.progress('close');	// 如果提交成功则隐藏进度条
                    parent.layer.msg(result.message,{time:1000,icon:2});
                }
            }
        });
    });

});
//参数清空
$('#cardReset').on('click',function () {
    $('#cardForm').form('reset');
});